<% add_decidim_page_title(t(".title")) %>
<% add_decidim_page_title(translated_attribute(result.title)) %>
<div class="card">
  <div class="item_show__header">
    <h1 class="item_show__header-title">
      <div>
        <%= link_to "#{translated_attribute(result.title)} > ", edit_result_path(result) %>
        <%= t(".title") %>
      </div>
      <%= link_to t("actions.new_milestone", scope: "decidim.accountability"), new_result_milestone_path(result), class: "button button__sm button__secondary button--title" if allowed_to? :create, :milestone %>
    </h1>
  </div>
  <div class="table-stacked">
    <table class="table-list">
      <thead>
        <tr>
          <th><%= t("models.milestone.fields.entry_date", scope: "decidim.accountability") %></th>
          <th><%= t("models.milestone.fields.title", scope: "decidim.accountability") %></th>
          <th><%= t("actions.title", scope: "decidim.accountability") %></th>
        </tr>
      </thead>
      <tbody>
        <% milestones.each do |milestone| %>
          <tr data-id="<%= milestone.id %>">
            <td data-label="<%= t("models.milestone.fields.entry_date", scope: "decidim.accountability") %>">
              <%= l milestone.entry_date, format: :decidim_short %><br>
            </td>
            <td data-label="<%= t("models.milestone.fields.title", scope: "decidim.accountability") %>">
              <%= translated_attribute(milestone.title) %>
            </td>
            <td class="table-list__actions" data-label="<%= t("actions.title", scope: "decidim.accountability") %>">
              <button type="button" data-controller="dropdown" data-target="actions-milestone-<%= milestone.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: translated_attribute(milestone.title)) %>">
                <%= icon "more-fill", class: "text-secondary" %>
              </button>

              <div class="inline-block relative">
                <ul id="actions-milestone-<%= milestone.id %>" class="dropdown dropdown__action" aria-hidden="true">
                  <% if allowed_to? :update, :milestone, milestone: milestone %>
                    <li class="dropdown__item">
                      <%= link_to edit_result_milestone_path(milestone.result, milestone), class: "dropdown__button" do %>
                        <%= icon "pencil-line" %>
                        <%= t("actions.edit", scope: "decidim.accountability") %>
                      <% end %>
                    </li>

                    <hr>
                  <% end %>

                  <% if allowed_to? :destroy, :milestone, milestone: milestone %>
                    <li class="dropdown__item">
                      <%= link_to result_milestone_path(milestone.result, milestone), method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.accountability") }, class: "dropdown__button dropdown__button--danger" do %>
                        <%= icon "delete-bin-line" %>
                        <%= t("actions.destroy", scope: "decidim.accountability") %>
                      <% end %>
                    </li>
                  <% end %>
                </ul>
              </div>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
<%= decidim_paginate milestones %>
